﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Rodunu.Services.IMDB;
using System.Collections.ObjectModel;
using Rodunu.Clients.WPF.Controls;

namespace Rodunu.Clients.WPF.Collection.Forms
{
    /// <summary>
    /// Interaction logic for IMDBSearchResults.xaml
    /// </summary>
    public partial class IMDBSearchResults
    {
        private readonly Controller _controller;

        public IMDBSearchResults()
        {
            InitializeComponent();

            if (_controller == null)
                _controller = new Controller();

            //ScrollViewer.SizeChanged += new SizeChangedEventHandler(ScrollViewer_SizeChanged);
            //IconList.SizeChanged += new SizeChangedEventHandler(IconList_SizeChanged);
        }

        public void GetSearchResults(string searchText)
        {
            if (searchText.Length > 0)
            {
                IList<SearchResult> results = _controller.SearchByTitle(searchText);
                //if (results.Count > 0)
                //    PopularTitles.Visibility = System.Windows.Visibility.Visible;
                //else
                //    PopularTitles.Visibility = System.Windows.Visibility.Collapsed;

                IconList.SetImages(DataHelper.ConvertSearchResultToTitles(results));
                //PopularTitles.ItemsSource = results;
                
            }
        }

        public string GetSelectedMovie()
        {
            return IconList.GetSelectedTitle().Id.ToString();
        }
    }
}
